package com.wn.controller;

import com.wn.feign.MemberFeignClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author yellow Docter
 * @date 2022 -10-26
 * @desc  测试hystrix 进行服务降级  (业务代码和 服务降级代码分开)
 *   服务降级
 *   1、出现了异常或者调用超时 会调用提前准备好的方法的预定值
 *
 *  解决方案：
 *   1、编写回调类，实现feign接口
 *   2、在feign接口中进行配置
 *     @FeignClient(
 *     value = "cinema-member-service",
 *     fallback = MemberFeignFallback.class)
 *     如果异常进行降级处理的调用

 */
@RestController
@RequestMapping("feign")
@Slf4j
public class Feign03Controller {

    @Autowired
    private MemberFeignClient memberFeignClient;

    @GetMapping("member/{mid}")

    public String findOne(@PathVariable("mid")String mid){
        // feign 的远程调用
        String one = memberFeignClient.findOne(mid);
        return one;
    }
//
//    @GetMapping("member")
//    public String findTimeOut(){
//        String timeOut = memberFeignClient.findTimeOut();
//        return timeOut;
//    }

}
